--- /dev/null
+unit delphi;\r
+\r
+// Delpi compatibility unit //\r
+\r
+interface\r
+\r
+uses\r
+ SysUtils, TypInfo;\r
+\r
+{$IFDEF VER120}\r
+function GetPropInfo(Instance: TObject; const PropertyName: string): PPropInfo; overload;\r
+function GetPropInfo(Instance: TObject; const Name: string; var PropInfo: TPropInfo): Boolean; overload;\r
+function GetObjectProp(Instance: TObject; Info: PPropInfo): TObject;\r
+function GetStrProp(Instance: TObject; const Name: string): string; overload;\r
+function GetStrProp(Instance: TObject; Info: PPropInfo): string; overload;\r
+procedure SetStrProp(Instance: TObject; const Name, Value: string); overload;\r
+procedure SetStrProp(Instance: TObject; Info: PPropInfo; const Value: string); overload;\r
+{$ENDIF}\r
+\r
+implementation\r
+\r
+{$IFDEF VER120}\r
+function GetPropInfo(Instance: TObject; const PropertyName: string): PPropInfo;\r
+begin\r
+ Result := TypInfo.GetPropInfo(Instance.ClassInfo, PropertyName);\r
+end;\r
+\r
+function GetObjectProp(Instance: TObject; Info: PPropInfo): TObject;\r
+begin\r
+ Result := Pointer(TypInfo.GetOrdProp(Instance, Info));\r
+end;\r
+\r
+function GetPropInfo(Instance: TObject; const Name: string; var PropInfo: TPropInfo): Boolean;\r
+var\r
+ Props: PPropList;\r
+ TypeData: PTypeData;\r
+ Info: PPropInfo;\r
+ i: Integer;\r
+begin\r
+ TypeData := GetTypeData(Instance.ClassInfo);\r
+ if ((TypeData <> nil) and (TypeData.PropCount > 0)) then\r
+ begin\r
+ GetMem(Props, TypeData.PropCount * SizeOf(Pointer));\r
+ try\r
+ GetPropInfos(Instance.ClassInfo, Props);\r
+ for i := 0 to TypeData.PropCount - 1 do\r
+ begin\r
+ Info := Props[i];\r
+ if (CompareText(Info.Name, Name) = 0) then\r
+ begin\r
+ PropInfo := Info^;\r
+ Result := True;\r
+ Exit;\r
+ end\r
+ end;\r
+ finally\r
+ FreeMem(Props);\r
+ end;\r
+ end;\r
+ Result := False;\r
+end;\r
+\r
+function GetStrProp(Instance: TObject; Info: PPropInfo): string;\r
+begin\r
+ Result := TypInfo.GetStrProp(Instance, Info);\r
+end;\r
+\r
+function GetStrProp(Instance: TObject; const Name: string): string;\r
+var\r
+ Info: TPropInfo;\r
+begin\r
+ if GetPropInfo(Instance, Name, Info) then\r
+ Result := TypInfo.GetStrProp(Instance, @Info)\r
+ else\r
+ Result := '';\r
+end;\r
+\r
+procedure SetStrProp(Instance: TObject; const Name, Value: string);\r
+var\r
+ Info: TPropInfo;\r
+begin\r
+ if GetPropInfo(Instance, Name, Info) then\r
+ SetStrProp(Instance, @Info, Value);\r
+end;\r
+\r
+procedure SetStrProp(Instance: TObject; Info: PPropInfo; const Value: string);\r
+begin\r
+ TypInfo.SetStrProp(Instance, Info, Value);\r
+end;\r
+\r
+{$ENDIF}\r
+\r
+end.\r